using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class BlueprintType : EveProperty
    {
        private int parentBlueprintTypeId;
        private int productTypeId;
        private int productionTime;
        private int techLevel;
        private int researchProductivityTime;
        private int researchMaterialTime;
        private int researchCopyTime;
        private int researchTechTime;
        private int productivityModifier;
        private int materialModifier;
        private int wasteFactor;
        private double chanceOfReverseEngineering;
        private int maxProductionLimit;

        private BlueprintType parentBlueprintType;
        private Type productType;

        public BlueprintType Parent
        {
            get
            {
                if (parentBlueprintTypeId != 0 && parentBlueprintType == null)
                    parentBlueprintType = new BlueprintType(db, parentBlueprintTypeId);
                return parentBlueprintType;
            }
        }
        public Type Product
        {
            get
            {
                if (productType == null)
                    productType = new Type(db, productTypeId);
                return productType;
            }
        }
        public int ProductionTime
        {
            get { return productionTime; }
        }
        public int TechLevel
        {
            get { return techLevel; }
        }
        public int ResearchProductivityTime
        {
            get { return researchProductivityTime; }
        }
        public int ResearchMaterialTime
        {
            get { return researchMaterialTime; }
        }
        public int ResearchTechTime
        {
            get { return researchTechTime; }
        }
        public int ProductivityModifier
        {
            get { return productivityModifier; }
        }
        public int MaterialModifier
        {
            get { return materialModifier; }
        }
        public int WasteFactor
        {
            get { return wasteFactor; }
        }
        public double ChanceOfReverseEngineering
        {
            get { return chanceOfReverseEngineering; }
        }
        public int MaxProductionLimit
        {
            get { return maxProductionLimit; }
        }

        internal BlueprintType(DbDataRow dr)
            : base(dr.Database, EvePropertyType.BlueprintType, dr["blueprintTypeID"])
        {
            Fill(dr);
        }
        internal BlueprintType(Database db, int id)
            : base(db, EvePropertyType.BlueprintType, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM invBlueprintTypes WHERE blueprintTypeID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            parentBlueprintTypeId = dr["parentBlueprintTypeID"];
            productTypeId = dr["productTypeID"];
            productionTime = dr["productionTime"];
            techLevel = dr["techLevel"];
            researchProductivityTime = dr["researchProductivityTime"];
            researchMaterialTime = dr["researchMaterialTime"];
            researchCopyTime = dr["researchCopyTime"];
            researchTechTime = dr["researchTechTime"];
            productivityModifier = dr["productivityModifier"];
            materialModifier = dr["materialModifier"];
            wasteFactor = dr["wasteFactor"];
            chanceOfReverseEngineering = dr["chanceOfReverseEngineering"];
            maxProductionLimit = dr["maxProductionLimit"];
        }
    }
}
